C.CurCredits = 0;

function umRefreshCredits( um )
	
	C.CurCredits = um:ReadLong();
	
end
usermessage.Hook( "RC", umRefreshCredits );

function umLiquifyResource( um )
	
	local num = um:ReadShort();
	local poss = { };
	
	for i = 1, num do
		
		table.insert( poss, um:ReadLong() );
		
	end
	
	local w = vgui.Create( "DFrame" );
	w:SetSize( 300, 200 );
	w:Center();
	w:SetTitle( "Sell Resources" );
	w:MakePopup();
	
	local t = vgui.Create( "DLabel", w );
	t:SetPos( 10, 30 );
	t:SetText( "What would you like to sell?" );
	t:SizeToContents();
	
	local y = 55;
	
	for _, v in pairs( poss ) do
		
		local b = vgui.Create( "DButton", w );
		b:SetPos( 10, y );
		b:SetText( string.upper( string.sub( RES_LANG[v], 1, 1 ) ) .. string.sub( RES_LANG[v], 2 ) );
		b:SetSize( 280, 24 );
		b.DoClick = function( self )
			
			RunConsoleCommand( "c_e_lr", tostring( v ) );
			
		end
		
		y = y + 30;
		
	end
	
	local b = vgui.Create( "DButton", w );
	b:SetPos( 10, y );
	b:SetText( "All" );
	b:SetSize( 280, 24 );
	b.DoClick = function( self )
		
		RunConsoleCommand( "c_e_lr", "0" );
		
	end
	
end
usermessage.Hook( "LR", umLiquifyResource );